﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace API.Models.Repository
{
    public class SEC_COMPANIES_ACCESS_Repository : GenericRepository<PartnerDbContext, SEC_COMPANIES_ACCESS>
    {
        public override IQueryable<SEC_COMPANIES_ACCESS> Find(System.Linq.Expressions.Expression<Func<SEC_COMPANIES_ACCESS, bool>> predicate)
        {
            IQueryable<SEC_COMPANIES_ACCESS> query = _entities.SEC_COMPANIES_ACCESS
                .Include("COMPANY")
                .Include("ALLOW_COMPANY");

            /// Фильтрация по заданному условию
            if (predicate != null)
                query = query.Where(predicate);

            if (session != null)
            {
                query = query
                    .Where(r => r.COMPANY_GUID == this.session.COMPANY_GUID)
                    .AsQueryable();
            }

            return query;
        }
    }
}